import java.util.Scanner;
import java.util.Stack;

public class Test {
    //编程题--判断子序列
    public boolean isSubsequence(String S,String T){
        int i=0;
        int j=0;
        while(i<S.length()&&j<T.length()){
            if(S.charAt(i)==T.charAt(j)){
                i++;
                j++;
            }else{
                j++;
            }
        }
        return i==S.length();
    }


    //点击消除
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        while(in.hasNextLine()){
            String str=in.nextLine();
            Stack<Character> stack=new Stack<>();
            for (int i = 0; i < str.length(); i++){
                char ch=str.charAt(i);
                if(stack.empty()||ch!=stack.peek()){//为空或者不是栈顶元素
                    stack.push(ch);//入栈
                }else{
                    stack.pop();//出栈
                }
            }
            //已经存好了数据
            if(stack.empty()){
                System.out.println("0");
            }else{
                Stack<Character> stack2=new Stack<>();
                while (!stack.empty()){
                    stack2.push(stack.pop());//剩余的元素存在新栈中
                }
                while (!stack2.empty()) {
                    stack2.push(stack2.pop()); //打印出来
                }
            }
        }
    }
}
